#ifndef DATAMANAGER_H
#define DATAMANAGER_H

#include <QWidget>
#include "tableView/tableviewheader.h"
#include <QStandardItemModel>
#include "Beans/datainfobean.h"

namespace Ui {
class DataManager;
}
typedef  struct DATAINFO_TABLE_DATA_T
{
    QString TaskID;//任务名称
    QString TaskType;//模式
    QString TaskTheme;//主题
    QString TaskContent;//内容
    QString MeasureTime;//时间
    DataInfoBean dib;

}DATAINFO_TABLE_DATA;

typedef QHash<QString, DATAINFO_TABLE_DATA> QHashDataInfoTable;
typedef QHash<QString, DATAINFO_TABLE_DATA>::iterator QHashDataInfoTableIterator;

class DataManager : public QWidget
{
    Q_OBJECT
    enum COLUMN_DATAINFO
    {
        COLUMN_CHECKBOX = 0,
        COLUMN_NO,
        COLUMN_ID,
        COLUMN_TYPE,
        COLUMN_THEME,
        COLUMN_CONTENT,
        COLUMN_MEASURETIME

    };

public:
    explicit DataManager(QWidget *parent = nullptr);
    ~DataManager();
    void QueryDataBase();

    void paintEvent(QPaintEvent *event);
    void initTableView();
    void setColumnWidth();
    void RefreshTable();

private slots:
    void on_pushButton_exit_clicked();
    void on_tableViewClick(QModelIndex nIndex);
    void on_tableViewDbClick(QModelIndex nIndex);
    void on_tableViewSort(int nColumn);
    void on_tableViewSelectAllCheckBoxClick(Qt::CheckState state);


    void on_pushButton_Query_clicked();

    void on_pushButton_Print_clicked();

    void on_pushButton_Delete_clicked();

    void on_pushButton_clicked();

private:
    Ui::DataManager *ui;
    QStandardItemModel *m_pTableModel;
    TableViewHeader *m_pTableHeader;
    int m_nCheckedCount;//选中个数
    QHashDataInfoTable m_dataInfoTableHash;
    QList<DataInfoBean>dibs;

};

#endif // DATAMANAGER_H
